package com.asia5b.a5mall.goods.adapter

import android.widget.TextView
import com.asia5b.a5mall.goods.R
import com.asia5b.a5mall.middleware.model.goods.SelectorBean
import com.asia5b.a5mall.middleware.model.goods.SelectorKeyBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Created by zhangyuncai on 2020/5/13.
 */
class GoodsCompValueAdapter(var selectorKeyBean: SelectorKeyBean) :
        BaseQuickAdapter<SelectorBean, BaseViewHolder>(R.layout.item_goodscomp_value_adapter, selectorKeyBean.value!!) {
    var selectSelectorBean:SelectorBean?=null
    override fun convert(helper: BaseViewHolder, item: SelectorBean) {
        val tv_goodscomp_value = helper.getView<TextView>(R.id.tv_goodscomp_value)
        tv_goodscomp_value.setText(item.name)
        tv_goodscomp_value.isSelected = item == selectSelectorBean
        tv_goodscomp_value.setOnClickListener {
            if (item == selectSelectorBean) {
                selectSelectorBean = null
            } else {
                selectSelectorBean = item
            }
            notifyDataSetChanged()
        }
    }
}